var { Point } = require("../Point");

/**
 *  顶点距离
 * @class Distances
 */
class Distances {
	/**
 *
 * @type {number[][]}
 * @static
 * @memberof Distances
 */
	static distances //:  {number}

	static NUM_PARTICLES

	static setNUM_PARTICLES(NUM_PARTICLES) {

		Distances.NUM_PARTICLES = NUM_PARTICLES
		Distances.distances = Array.from(new Array(Distances.NUM_PARTICLES), v => {
			return new Array(Distances.NUM_PARTICLES)
		})
	}
	static getDistances(list) {
		var distances = Distances.distances
		var NUM_PARTICLES = Distances.NUM_PARTICLES
		for (var i = 0; i < NUM_PARTICLES; i++) {
			distances[i][i] = 0
			for (let j = i + 1, length2 = NUM_PARTICLES; j < length2; j++) {
				distances[j][i] = distances[i][j] = Point.len(list[i], list[j]);
			}
		}
		return distances
	}

	/**
	 *
	 * @static
	 * @param {Point[]} list
	 * @param {Point[]} list2
	 * @returns {number[][]}
	 * @memberof Distances
	 */
	static get2Distances(list, list2) {
		var distances = Array.from(new Array(list.length), () => {
			return new Array(list2.length);
		});
		for (var i = 0, len1 = list.length; i < len1; i++) {
			for (let j =	0, length2 = list2.length; j < length2; j++) {
				 distances[i][j] = Point.len(list[i], list2[j]);
			}
		}
		return distances
	}
}
module.exports = Distances